package com.chenwenxuan.sync.ui;

import java.awt.event.ActionEvent;
import java.util.List;

import javax.swing.Icon;
import javax.swing.JPopupMenu;
import javax.swing.tree.DefaultMutableTreeNode;

import com.chenwenxuan.sync.event.IEventHandler;
import com.chenwenxuan.sync.event.IEventSource;

public abstract class AbstractAction extends javax.swing.AbstractAction implements
		IEventHandler {

	private static final long serialVersionUID = 950276865430573843L;
	
	private List <String> navigationEvents;
	private String actionId;
	private String parentActionId;
	
	public abstract void fillNavMenu(MenuManager menuManager, DefaultMutableTreeNode [] selected);
	public abstract void doIt(ActionEvent e);
	public abstract boolean canOpenEditor(Object userObject);
	
	public boolean isDefaultAction() {
		return false;
	}

	@Override
	public final void handleEvent(IEventSource source, String event, Object params) {
		
		MenuManager manager = (MenuManager) source;
		DefaultMutableTreeNode[] selected= ((DefaultMutableTreeNode[])params);

		fillNavMenu( manager, selected );
	}

	@Override
	public final void actionPerformed(ActionEvent e) {
		doIt(e);
	}
	
	public List<String> getNavigationEvents() {
		return navigationEvents;
	}
	
	public void setNavigationEvents(List<String> navigationEvents) {
		this.navigationEvents = navigationEvents;
	}

	public AbstractAction() {
		super();
	}
	public AbstractAction(String name, Icon icon) {
		super(name, icon);
	}
	public AbstractAction(String name) {
		super(name);
	}
	public String getActionId() {
		return actionId;
	}
	public void setActionId(String actionId) {
		this.actionId = actionId;
	}
	public String getParentActionId() {
		return parentActionId;
	}
	public void setParentActionId(String parentActionId) {
		this.parentActionId = parentActionId;
	}


}
